package com.zhdl.hardware_contact.hardware_common.repository.impl;

import com.zhdl.hardware_contact.hardware_common.repository.TCPIPCmdHandleService;
import com.zhdl.network.strategy.common_client.dto.SendReceiverData;
import com.zhdl.network.strategy.common_server.impl.CommonServerSendServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service("TCPIPCmdHandleServiceImpl")
public class TCPIPCmdHandleServiceImpl implements TCPIPCmdHandleService {

    @Resource
    private CommonServerSendServiceImpl commonServerSendServiceImpl;

    @Override
    public void addTCPIp(SendReceiverData sendReceiverData) {
        if (sendReceiverData.getPort() == null || sendReceiverData.getPort().isEmpty()) {
            log.error("当前TCP IP添加失败，未获取到输入的IP地址");
        } else {
            commonServerSendServiceImpl.addServer(sendReceiverData.getPort());
        }
    }
}
